package com.yonyou.rabbitmq.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.LinkedHashMap;

@Component
@Data
@Slf4j
@ConfigurationProperties(prefix = "rabbitmq")
public class RabbitConfig {

    private String prefix;

    public LinkedHashMap<String,QueueInfo> queues;

    private long ttl = 60 * 60 * 1000;//队列过期时间，默认60分钟

    public String[] queueNames(LinkedHashMap<String,QueueInfo> queues){
        Collection<QueueInfo> queueInfos = queues.values();
        return queueInfos.stream().map(q->q.name).toArray(String[]::new);
    }

    @Data
    public static class QueueInfo{
        private String name;
        private boolean delay = false;
    }
}
